package services.common;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import models.common.bean.CompanyAuditInfo;
import models.common.bean.CompanyUserBean;
import models.common.bean.MonthlySummary;
import models.common.entity.t_company_info;
import models.common.entity.t_company_info_side;
import models.common.entity.t_credit_limit;

import org.apache.commons.lang.StringUtils;

import services.base.BaseService;
import common.enums.AuditStatus;
import common.enums.Client;
import common.enums.CompanyInfoType;
import common.enums.MemberType;
import common.enums.NoticeScene;
import common.utils.Factory;
import common.utils.LoggerUtil;
import common.utils.PageBean;
import common.utils.ResultInfo;
import common.utils.StrUtil;
import daos.common.CompanyInfoDao;
import daos.common.UserDao;

/**
 * 企业信息service
 *
 * @description 
 *
 * @author zhiliang.lan
 * @createDate 2017年4月15日
 */

public class CompanyInfoService extends BaseService<t_company_info>{
	
	protected CompanyInfoDao companyInfoDao = Factory.getDao(CompanyInfoDao.class);
	
	protected static UserDao userDao = Factory.getDao(UserDao.class);
	
	protected static UserService userService = Factory.getService(UserService.class);
	
	protected static NoticeService noticeService = Factory.getService(NoticeService.class);
	
	protected static CompanyInfoSideService companyInfoSideService = Factory.getService(CompanyInfoSideService.class);	
	
	protected static NoticeService noticeservice = Factory.getService(NoticeService.class);
	
	protected CompanyInfoService(){
		super.basedao = companyInfoDao;
	}
	
	
	/**
	 * 根据user_id查询t_company_info
	 * 
	 * @param user_id
	 * @return
	 *
	 * @author liaijun
	 * @createDate 2017年4月15日
	 */
	public t_company_info findCompanyInfoByUserId(long userId) {

		return companyInfoDao.findCompanyByUserId(userId);
	}
	
	/**
	 * 根据user_id查询t_company_info
	 * 
	 * @param user_id
	 * @return
	 *
	 * @author liaijun
	 * @createDate 2017年4月15日
	 */
	public t_company_info findCompanyInfoSideByUserId(long userId) {
		
		return companyInfoDao.findCompanyInfoSideByUserId(userId);
	}

	/**
	 * 获取保理企业
	 * @author liaijun
	 * @createDate 2017年4月15日
	 */
	public List<t_company_info> findCompanyInfoByType() {
		return companyInfoDao.findListByColumn("company_type_id=?",(long)CompanyInfoType.FACTOR_COMPANY.code);
	}
	/**
	 * 获取质押商票代理企业
	 * @author liaijun
	 * @createDate 2017年4月15日
	 */
	public t_company_info findPledgeCompanyInfoByType() {
		return companyInfoDao.findByColumn("company_type_id=?", (long)CompanyInfoType.THIRD_PARTY_COMPANY.code);
	}
	/**
	 * 根据user_id查询t_company_info
	 * 
	 * @param userId
	 * @return
	 *
	 * @author zhiliang.lan
	 * @createDate 2017年4月21日
	 */
	public t_company_info findUserInfoByUserId(long userId) {
		
		return companyInfoDao.findByColumn("user_id = ?", userId);
	}
	
	/**
	 * 修改企业基本资料审核信息
	 * @param userId 用户Id
	 * @return
	 * @author zhiliuang.lan
	 * @createDate 2017年4月21日15:44:43
	 */
	public ResultInfo updateCompanyBasicInfoAuditInfo(t_company_info companyInfo) {
		ResultInfo result = new ResultInfo();
		boolean isFlag = companyInfoDao.save(companyInfo);
		if (!isFlag) {
			result.code = -1;
			result.msg= "审核个人信息失败";
			
			return result;
		}
		result.code = 1;
		result.msg= "审核个人信息成功";
		
		return result;
	}


	/**
	 * 查询所有子类型，包括条件查询
	 * 
	 * @param currPage
	 * @param pageSize
	 * @param infoType
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年4月24日
	 */
	public PageBean<CompanyAuditInfo> pageOfAuditiInfoByInfoType(int currPage,
			int pageSize, String infoType) {

		StringBuffer countSQL = new StringBuffer("SELECT COUNT(1) FROM t_deal_platform tdp LEFT JOIN t_user tu ON tdp.user_id = tu.id WHERE 1=1");
		StringBuffer querySQL = new StringBuffer("SELECT tdp.id AS id,  tdp.time AS time ,tdp.operation AS operation,  tdp.user_id AS user_id,  tdp.amount AS amount,  tdp.type AS type, tdp.remark AS remark,tu.name AS name FROM t_deal_platform tdp LEFT JOIN t_user tu ON tdp.user_id = tu.id WHERE 1=1");
		
		Map<String, Object> condition = new HashMap<String, Object>();
		
		if(StringUtils.isNotBlank(infoType)){
			countSQL.append(" AND tu.name LIKE :userName ");
			querySQL.append(" AND tu.name LIKE :userName ");
			condition.put("type", "%"+infoType+"%");
		}
		
		querySQL.append(" ORDER BY id DESC");
		
		
		return companyInfoDao.pageOfBeanBySQL(currPage, pageSize, countSQL.toString(), querySQL.toString(), CompanyAuditInfo.class,condition);
		
	}

	/**
	 * 根据企业全称查询
	 * @param name 字段名（企业全称）
	 * @param full_name  参数
	 * @return
	 * @author xiaojun
	 * @createDate 2017年4月24日
	 */
	public  t_company_info findIDByName(String name,String full_name){
		return companyInfoDao.findByColumn(name,full_name);
	}
	/**
	 * 根据企业全称查询
	 * @param user_id 字段名（用户user_id）
	 * @return
	 * @author liaijun
	 * @createDate 2017年6月9日
	 */
	public  long findCompanyId(long user_id){
		return companyInfoDao.findCompanyId(user_id);
	}

	/**
	 * 更新保存企业信息
	 * 
	 * @param companyInfo
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年4月25日
	 */
	public ResultInfo updateCompanyInfo(t_company_info companyInfo) {
		ResultInfo result = new ResultInfo();
		boolean isFlag = companyInfoDao.save(companyInfo);
		if (!isFlag) {
			result.code = -1;
			result.msg= "更新企业信息失败";
			
			return result;
		}
		result.code = 1;
		result.msg= "更新企业信息成功";
		
		return result;
	}


	/**
	 * 更新企业用户信息
	 * @param business_license_code
	 * @param province_id
	 * @param city_id
	 * @param company_work_address
	 * @param company_license_permit
	 * @param company_credit_card
	 * @param legal_person_name
	 * @param license_card_type
	 * @param license_code
	 * @param license_card_pic_on
	 * @param license_card_pic_under
	 * @param legal_person_mobile
	 * @param legal_person_tel
	 * @param legal_person_address
	 * @param legal_person_email
	 * @param agent_name
	 * @param certificate_type
	 * @param agent_card_number
	 * @param agent_card_on
	 * @param agent_card_under
	 * @param agent_address
	 * @param company_legal_person_proxy_pic
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年5月8日
	 */
	public ResultInfo updateCompanyInformation(long companyId,String business_license_code,
			int province_id, int city_id, String company_work_address,
			String company_license_permit, String company_credit_card,
			String legal_person_name, int license_card_type,
			String license_code, String license_card_pic_on,
			String license_card_pic_under, String legal_person_mobile,
			String legal_person_tel, String legal_person_address,
			String legal_person_email, String agent_name, int certificate_type,
			String agent_card_number, String agent_card_on,
			String agent_card_under, String agent_address,
			String company_legal_person_proxy_pic) {
		
		int i = companyInfoDao.updateCompanyInformation(companyId,business_license_code,province_id,city_id,company_work_address,
				company_license_permit,company_credit_card,legal_person_name,license_card_type,
				license_code,license_card_pic_on,license_card_pic_under,legal_person_mobile,
				legal_person_tel,legal_person_address,legal_person_email,agent_name,certificate_type,
				agent_card_number,agent_card_on,agent_card_under,agent_address,company_legal_person_proxy_pic);
		ResultInfo result = new ResultInfo();
		if (i < 0) {
			result.code = -1;
			result.msg = "企业信息修改失败";
			
			return result;
		}
		result.code = 1;
		result.msg = "企业信息修改成功";
		
		return result;
	}


	/**
	 * 添加企业基本信息
	 * @param id
	 * @param client
	 * @param fullName
	 * @param shortName
	 * @param businessLicenseCode
	 * @param agentName
	 * @param agentTel
	 * @param agentEmail
	 * @param agentMobile
	 * @return
	 * @author zhiliang.lan
	 * @param samll_amount 
	 * @createDate 2017年5月8日
	 */
	public boolean addCompanyInfo(long id, Client client, String fullName,
			String shortName, String businessLicenseCode, String agentName,
			String agentTel, String agentEmail, String agentMobile,long company_type_id, double samll_amount) {
		
		t_company_info companyInfo =  new t_company_info();
		companyInfo.user_id = id;
		companyInfo.setClient(client.PC);
		companyInfo.full_name = fullName;
		companyInfo.short_name = shortName;
		companyInfo.business_license_code = businessLicenseCode;
		companyInfo.agent_name = agentName;
		companyInfo.agent_tel = agentTel;
		companyInfo.agent_email = agentEmail;
		companyInfo.agent_mobile = agentMobile;
		companyInfo.time = new Date();
		companyInfo.small_amount = samll_amount;
		companyInfo.company_type_id = company_type_id;
		//默认照片暂时没有
		
		return companyInfoDao.save(companyInfo);
	}


	/**
	 * 平台注册企业列表
	 * 
	 * @param currPage
	 * @param pageSize
	 * @param province_id
	 * @param city_id
	 * @param company_type_id
	 * @param fullName
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年5月9日
	 */
	public PageBean<Map<String, Object>> pageOfPlatformCompany(int currPage,int pageSize, 
			long userId,int province_id, int city_id, long credit_level_id ,long company_type_id, long industry_type_id,
			String fullName){
			
		
		return companyInfoDao.pageOfPlatformCompany(currPage,pageSize,userId,
				province_id,city_id,credit_level_id,company_type_id,industry_type_id,fullName);
	}


	/**
	 * 已关注企业
	 * @param currPage
	 * @param pageSize
	 * @param province_id
	 * @param city_id
	 * @param company_type_id
	 * @param fullName
	 * @return
	 * @author zhiliang.lan
	 * @param userId 
	 * @createDate 2017年5月9日
	 */
	public PageBean<Map<String, Object>> pageOfConcernedCompany( int currPage,int pageSize,long userId,
			 int province_id, int city_id, long credit_level_id ,long company_type_id,long industry_type_id,
			String fullName){

		return companyInfoDao.pageOfConcernedCompany( currPage,pageSize,userId,province_id,city_id,credit_level_id,
				company_type_id,industry_type_id,fullName);
	}


	/**
	 * 黑名单企业
	 * 
	 * @param currPage
	 * @param pageSize
	 * @param province_id
	 * @param city_id
	 * @param company_type_id
	 * @param fullName
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年5月9日
	 */
	public PageBean<Map<String, Object>> pageOfBlackCompany(int currPage,
			int pageSize, int province_id, int city_id,long credit_level_id ,long company_type_id,long industry_type_id,
			String fullName) {
		
		return companyInfoDao.pageOfBlackCompany(currPage,pageSize,province_id,city_id,credit_level_id,company_type_id,industry_type_id,fullName);
	}


	/**
	 * 查企业信息和对应的交易信用积分信息
	 * @param userId
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年5月11日
	 */
	public t_company_info findCompanyInfoAndCreditLevelByUserId(long userId) {
		
		return companyInfoDao.findCompanyInfoAndCreditLevelByUserId(userId);
	}
	/**
	 * 查企业信息和对应的交易信用积分信息
	 * @param userId
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年5月11日
	 */
	public Map<String, Object> findCompanyInfoAndCreditLevelByUserId2(long userId) {
		
		return companyInfoDao.findCompanyInfoAndCreditLevelByUserId2(userId);
	}
	
	/**
	 * 判断一个邮箱是否已经存在，存在则返回true，不存在返回false
	 * @param email
	 * @return
	 *
	 * @author zhiliang.lan
	 * @createDate 2017年5月12日15:48:52
	 */
	public boolean isEmailExists(String email) {
		t_company_info companyInfo = companyInfoDao.findCompanyInfoByAgentEmail(email);
		if (companyInfo != null) {
			return true;
		}
		
		return false;
	}


	/**
	 * 获取所有企业信息
	 * 
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年5月15日
	 */
	public List<t_company_info> findAllCompany() {
		
		return companyInfoDao.findAll();
	}

	/**
	 * 判断企业全称是否已经存在，存在则返回true，不存在返回false
	 * 
	 * @param fullName 企业全称
	 * @return 返回Boolean值，存在返回true，不存在false
	 * 
	 * @author zhiliang.lan
	 * @createDate 2017年5月19日09:01:24
	 */
	public boolean isCompanyFullName(String fullName) {
		t_company_info companyInfo = companyInfoDao.findByColumn("full_name=? ",fullName);
		if (companyInfo != null) {
			return true;
		}
		return false;
	}


	/**
	 * 判断企业简称是否已经存在，存在则返回true，不存在返回false
	 * 
	 * @param shortName 企业简称
	 * @return 返回Boolean值，存在返回true，不存在false
	 * 
	 * @author zhiliang.lan
	 * @createDate 2017年5月19日09:10:56
	 */
	public boolean isCompanyShortNameExists(String shortName) {
		t_company_info companyInfo = companyInfoDao.findByColumn("short_name=? ",shortName);
		if (companyInfo != null) {
			return true;
		}
		return false;
	}


	/**
	 * 判断企业营业执照编号是否已经存在，存在则返回true，不存在返回false
	 * 
	 * @param businessLicenseCode 企业营业执照编号
	 * @return 返回Boolean值，存在返回true，不存在false
	 * 
	 * @author zhiliang.lan
	 * @createDate 2017年5月19日09:14:38
	 */
	public boolean isCompanyBusinessLicenseCodeExists(String businessLicenseCode) {
		t_company_info companyInfo = companyInfoDao.findByColumn("business_license_code=? ",businessLicenseCode);
		if (companyInfo != null) {
			return true;
		}
		return false;
	}


	/**
	 * 清除用户实名认证信息
	 * 
	 * @param userId 用户ID
	 * @param realityName 真实姓名
	 * @param idNumber 身份证号码
	 * @return
	 *
	 * @author zhiliang.lan
	 * @createDate 2017年5月22日10:21:14
	 */
	public ResultInfo updateRealName(long userId, String realityName, String idNumber) {
		ResultInfo result = new ResultInfo();
		
		int i = companyInfoDao.updateRealName(userId, realityName, idNumber);
		
		if (i < 1) {
			result.code = -1;
			result.msg = "企业实名信息清除失败";
			
			return result;
		}
		
		result.code = 1;
		result.msg = "企业实名信息清除成功";
		
		return result;
	}
	
	/**
	 * 更新会员类型
	 *
	 * @param userId 用户ID
	 * @param memberType 会员类型枚举
	 * @author liaijun
	 * @createDate 2017年5月23日
	 */
	public boolean updateUserMemberType(long userId, MemberType memberType) {
		t_company_info company_info =  findCompanyInfoByUserId(userId);
		if (company_info == null) {
			LoggerUtil.info(true, "更新会员类型时，用户信息不存在。[userId:%s]", userId);
			
			return false;
		}

		return  companyInfoDao.updateUserMemberType(userId, memberType, company_info.getMember_type());
	}

	/***
	 * 根据营业执照查找信息
	 * @param code
	 * @return
	 */
	public boolean companyLicense(String code) {
		t_company_info user=this.companyInfoDao.findByColumn("lower(business_license_code)=lower(?)", code.trim());
		if (user!=null){
			return true;
		}
		return false;
	}


	/**
	 * 查企业,关注, 企业信用，行业类型，已挂牌次数，摘牌成功次数
	 * 
	 * @param userId
	 * @return
	 * @author zhiliang.lan
	 * @param companyId 
	 * @createDate 2017年6月13日
	 */
	public Map<String, Object> findCompanyInfoAndCreditLevelByUserId3(
			long userId, long companyUserId) {
		
		return companyInfoDao.findCompanyInfoAndCreditLevelByUserId3(userId, companyUserId);
	}

	/**
	 * 根据用户ID查找信用积分跟图标
	 * @param user_id
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年6月15日
	 */
	public Map<String, Object> findByCreditImg(long user_id) {
		
		return companyInfoDao.findByCreditImg(user_id);
	}
	/**
	 * 更新积分
	 * @param user_id
	 * @param score
	 * @return
	 * @author xiaojun
	 *@version 2018年1月31日
	 */
    public int updateCred(long user_id,int score){
    	return companyInfoDao.updateCred(user_id, score);
    }
	/**
	 * 后台审核修改查找营业执照是否存在
	 * @param code 营业执照号
	 * @param id
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年6月16日
	 */
	public boolean updateFindLicense(String code, String id) {
		t_company_info_side user=this.companyInfoSideService.updateFindLicense(code.trim(),id);
		if (user!=null){
			return true;
		}
		return false;
	}

	/**
	 * 后台审核查找企业全称是否存在
	 * @param full_name 企业全称
	 * @param id 
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年6月16日
	 */
	public boolean checkCompanyFullName(String full_name, String id) {
		t_company_info_side user=this.companyInfoSideService.checkCompanyFullName(full_name.trim(),id);
		if (user!=null){
			return true;
		}
		return false;
	}

	/**
	 * 修改企业全称与营业执照
	 * @param business_license_code 营业执照
	 * @param full_name 企业全称
	 * @param id
	 * @param user_id 用户id
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年6月16日
	 */
	public ResultInfo updateAuthenticate(String business_license_code, String full_name, long  id) {
		ResultInfo result=new  ResultInfo();
		t_company_info_side companyInfo = companyInfoSideService.findByID(id);
		
		if (companyInfo==null){
			result.code=-1;
			result.msg="未查询到企业信息";
			return result;
		}
		
		int in=companyInfoDao.updateAuthenticate(business_license_code,full_name,id);
		if (in<0){
			result.code=-1;
			result.msg="修改企业全称与营业执照号失败";
			return result;
		}
		result.code=1;
		result.msg="修改成功";
		return result;
	}

	/**
	 * 修改邮箱
	 * @param id
	 * @param email
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年6月17日
	 */
	public boolean updateEmail(long userId, String email) {
		int in=companyInfoDao.updateEmail(userId,email);
		if (in < 0){
			return true;
		}
		return false;
	}
	
	/**
	 * 企业全称补全
	 * @param name
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年6月19日
	 */
	public List<Map<String, Object>> findCompanyFullName(String name) {
		
		return companyInfoDao.findCompanyFullName(name);
	}


	/**
	 * 把副表信息更新到主表,传入参数 ：副表对象，主表对象
	 * 
	 * @param companyInfoSide
	 * @param companyInfo
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年6月22日
	 */
	public ResultInfo updateSideToMain(t_company_info_side companyInfoSide,
			t_company_info companyInfo) {
		
		ResultInfo result = new ResultInfo();
		
		//更新所有字段信息
		 companyInfo = findByID(companyInfo.id);
		companyInfo.user_id = companyInfoSide.user_id;
		companyInfo.logo = companyInfoSide.logo;
		companyInfo.full_name = companyInfoSide.full_name;
		companyInfo.short_name = companyInfoSide.short_name;
		companyInfo.time = companyInfoSide.time;
		companyInfo.setClient(companyInfoSide.getClient());
		companyInfo.business_license_code = companyInfoSide.business_license_code;
		companyInfo.business_license_code_pic = companyInfoSide.business_license_code_pic;
		companyInfo.agent_name = companyInfoSide.agent_name;
		companyInfo.agent_mobile = companyInfoSide.agent_mobile;
		companyInfo.agent_tel = companyInfoSide.agent_tel;
		companyInfo.setCertificate_type(companyInfoSide.getCertificate_type());
		companyInfo.agent_card_number = companyInfoSide.agent_card_number;
		companyInfo.agent_card_on = companyInfoSide.agent_card_on;
		companyInfo.agent_card_under = companyInfoSide.agent_card_under;
		companyInfo.agent_address = companyInfoSide.agent_address;
		companyInfo.agent_email = companyInfoSide.agent_email;
		companyInfo.company_agent_person_proxy_pic = companyInfoSide.company_agent_person_proxy_pic;
		companyInfo.company_license_pic = companyInfoSide.company_license_pic;
		companyInfo.company_work_address = companyInfoSide.company_work_address;
		companyInfo.company_license_permit = companyInfoSide.company_license_permit;
		companyInfo.company_credit_card = companyInfoSide.company_credit_card;
		companyInfo.setLicense_card_type(companyInfoSide.getLicense_card_type());
		companyInfo.license_code = companyInfoSide.license_code;
		companyInfo.license_card_pic_on = companyInfoSide.license_card_pic_on;
		companyInfo.license_card_pic_under = companyInfoSide.license_card_pic_under;
		companyInfo.legal_person_name = companyInfoSide.legal_person_name;
		companyInfo.legal_person_mobile = companyInfoSide.legal_person_mobile;
		companyInfo.legal_person_tel = companyInfoSide.legal_person_tel;
		companyInfo.legal_person_address = companyInfoSide.legal_person_address;
		companyInfo.legal_person_email = companyInfoSide.legal_person_email;
		companyInfo.company_legal_person_proxy_pic = companyInfoSide.company_legal_person_proxy_pic;
		companyInfo.province_id = companyInfoSide.province_id;
		companyInfo.city_id = companyInfoSide.city_id;
		companyInfo.setCa_authentication_status(companyInfoSide.getCa_authentication_status());
		companyInfo.credit_point = companyInfoSide.credit_point;
		companyInfo.credit_level_id = companyInfoSide.credit_level_id;
		companyInfo.setMember_type(companyInfoSide.getMember_type());
		companyInfo.invest_member_time = companyInfoSide.invest_member_time;
		companyInfo.company_type_id = companyInfoSide.company_type_id;
		companyInfo.industry_type_id = companyInfoSide.industry_type_id;
		companyInfo.open_account = companyInfoSide.open_account;
		companyInfo.open_bank = companyInfoSide.open_bank;
		companyInfo.setIs_black(companyInfoSide.getIs_black());
		companyInfo.black_reason = companyInfoSide.black_reason;
		companyInfo.small_amount = companyInfoSide.small_amount;
		companyInfo.company_authenticate_status = companyInfoSide.company_authenticate_status;
		companyInfo.setBasic_info_audit_status(companyInfoSide.getBasic_info_audit_status());
		companyInfo.setAuthenticate_status(companyInfoSide.getAuthenticate_status());
		companyInfo.basic_info_score = companyInfoSide.basic_info_score;
		companyInfo.agent_account = companyInfoSide.agent_account;
		companyInfo.agent_back_mobile = companyInfoSide.agent_back_mobile;
		companyInfo.legal_account = companyInfoSide.legal_account;
		companyInfo.legal_back_mobile = companyInfoSide.legal_back_mobile;
		companyInfo.small_amount_pic = companyInfoSide.small_amount_pic;
		//保存
		boolean isFlag = companyInfoDao.save(companyInfo);
		if (!isFlag) {
			result.code = -1;
			result.msg= "更新信息失败";
			return result;
		}
		result.code = 1;
		result.msg= "更新信息成功";
		
		return result;
	}
	
	/**
	 * 依据企业的类型进行查询
	 * @Title: queryCompanyByType 
	 * @param  type 类型
	 * @return: t_company_info
	 * @date: 2017年6月28日 下午4:27:47 
	 * @version: V1.0
	 */
	public t_company_info queryCompanyByType(long type){
	  return companyInfoDao.findByColumn("company_type_id =?", type);
	}


	/**
	 * 根据企业全称查企业
	 * @param company_full_name
	 * @return
	 * @author zhiliang.lan
	 * @createDate 2017年7月10日
	 */
	public t_company_info findCompanyByFullName(String company_full_name) {
		
		return companyInfoDao.findCompanyByFullName(company_full_name);
	}

	/**
	 * 后台 修改会员手机号
	 * @param id
	 * @param mobile 手机号
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年7月27日
	 */
	public ResultInfo updateUserMobile(long id, String mobile) {
		ResultInfo result=new ResultInfo();
		int type=companyInfoDao.updateUserMobile( id,  mobile);
		if (type < 1){
			result.code=-1;
			result.msg="修改手机失败";
			return result;
		}
		result.code=1;
		result.msg="修改手机成功";
		return result;
	}

	/**
	 * 后台审核评估资料审核通过更新主表状态
	 * @param id
	 * @param score
	 * @return
	 * @author binghui.zhou
	 * @createDate 2017年8月24日
	 */
	public ResultInfo updateCompanyInfoBackstageEvaluating(Long id, int score,int status) {
		ResultInfo result = new ResultInfo();
		int type = companyInfoDao.updateCompanyInfoBackstageEvaluating(id,score,status);
		if (type < 1 ){
			result.code = -1;
			result.msg= "更新审核信息失败";
			LoggerUtil.error(true, "更新企业基本信息失败");
			return result;
		}
		result.code = 1;
		result.msg= "更新审核信息成功";
		
		return result;
	}


	/**
	 * 分页查询 查询放款人
	 * 
	 * @param currPage
	 * @param pageSize
	 * @return
	 * 
	 * @author fanghanyong
	 * @createDate 2018年01月12日
	 * 
	 */
	public PageBean<t_company_info> pageOfCompanyInfo(
			int currPage, int pageSize) {

		return companyInfoDao.pageOfCompanyInfo(currPage, pageSize);
	}


	/**
	 *	根据用户id查询企业信息
	 * @param userId 用户id
	 * @return
	 * @author LiangQiongfeng
	 *@version 2018-1-22 
	 */
	public t_company_info findByUserId(long userId) {
		
		return companyInfoDao.findByUserId(userId);
	}

	/**
	 * 依据企业的类型进行查询
	 * @param type 企业类型
	 * @return
	 * @author fanghanyong
	 *@version 2018-1-29 
	 */
	public List<t_company_info> findCompanyByType(long type){
	  return companyInfoDao.findListByColumn("company_type_id =?", type);
	}
	/**
	 * 发送给当前企业进行小额鉴定
	 * @param company_info_side
	 * @author liiajun
	 *@version 2018年2月6日
	 */
	public void sendMsgForUser(t_company_info_side company_info_side){
	  if (company_info_side.getAuthenticate_status() == AuditStatus.NOT_SUBMIT) {
		Map<String, Object> contents = new HashMap<String, Object>();
		contents.put("user_name", company_info_side.full_name);
	    noticeservice.sendSysNotice(company_info_side.user_id, NoticeScene.BID_SMALL_TO_TM, contents);
	  }	
	}


	/**
	 *	利用用户名，手机号，邮箱，企业简称等查询企业信息
	 * @param mobile
	 * @return
	 * @author liangqiongfeng
	 *@version 2018-2-23 
	 */
	public t_company_info findByName(String mobile) {
		return companyInfoDao.findByName(mobile);
	}

	/**
	 *	根据输入名称查询企业信息
	 * @param companyName 企业全称
	 * @return
	 * @author LiangQiongfeng
	 *@version 2018-1-23 
	 */
	public t_company_info findByCompanyName(String companyName) {
		// TODO Auto-generated method stub
		return companyInfoDao.findByCompanyName(companyName);
	}
	
	/**
	 *	根据输入名称查询企业信息
	 * @param companyName 企业全称，简称，模糊查询
	 * @return
	 * @author LiangQiongfeng
	 *@version 2018-02-08
	 */
	public t_company_info findByLikeCompanyName(String companyName) {
		// TODO Auto-generated method stub
		return companyInfoDao.findByLikeCompanyName(companyName);
	}

}
